Skip to content

More performance improvements.#2

Open
johncarney wants to merge 2 commits intomasterfrom
performance-plus
Open

More performance improvements.#2
johncarney wants to merge 2 commits intomasterfrom
performance-plus

Conversation

@johncarney
Copy link
Copy Markdown
Owner

Builds on the previous performance-related pull request with a more radical variation on the class version of memoize. This time it defines a method that replaces itself with an attr_reader before setting the instance variable using the supplied block. This makes the first call to the memorised method very expensive, but subsequent calls become very cheap.

In testing, this yielded an impressive performance improvement when a memoized method was called a very large number of times in a given instance's lifetime. However, the break-even point was about 200 calls, so it's not really practical, but I thought I'd put it up for interest's sake.

@johncarney johncarney closed this Jul 16, 2015
@johncarney johncarney reopened this Jul 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant